﻿using System;
using NUnit.Framework;

namespace dnp.UnitTestEx.Test
{
    [TestFixture]
    public class SerializerTest
    {
        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void Serialize_DeriviedType_Fail()
        {
            MockObjects.EntityA A = new MockObjects.EntityAA { Age = 20 };

            var xml = Testing.IO.Serializer.Serialize(A);         
        }

        [Test]
        public void Serialize_DeriviedType_Pass()
        {
            MockObjects.EntityA A = new MockObjects.EntityAA { Age = 20 };

            var xml = Testing.IO.Serializer.Serialize(A, typeof(MockObjects.EntityAA));

            var entity = Testing.IO.Serializer.Deserialize<MockObjects.EntityA>(xml, typeof(MockObjects.EntityAA));

            Testing.Compare(A, entity);
        }
    }
}
